package com.physics.game;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.World;


public class StandardPhysicsWorld implements PhysicsWorld{

	private World world;
	
	static final int BOX_VELOCITY_ITERATIONS = 6;
	static final int BOX_POSITION_ITERATIONS = 2;
	
	
	public StandardPhysicsWorld(ContactListener listener){
		
		this.world = new World(new Vector2(0,-10), true);
		
		this.setListener(listener);
		
		
		
	}
	
	@Override
	public void update(float dt) {
		
		this.world.step(dt, BOX_VELOCITY_ITERATIONS, BOX_POSITION_ITERATIONS);
	}
	

	@Override
	public Body createBody(BodyDef bodydef){
		
		
		return this.world.createBody(bodydef);
		
	}
	
    
	
	
	@Override
	public void dispose() {
		world.dispose();
		
	}

	@Override
	public void setListener(ContactListener listener) {
		
		this.world.setContactListener(listener);
		
	}

}
